﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BikePartsManager
{
    class Bike
    {
        #region Attributes

        private int _idCounter;
        private int _id;
        private string _brand;
        private string _model;
        private BikeType _type;
        private int _cylinder;
        private DateTime _dateProd;
        private DateTime _dateBuy;
        private int _insurancePrice;
        private int _argus;
        private string _infos;
        private BuyType _bType;
        private List<Part> _parts;

        #endregion

        #region Methods

        public Bike()
        {
            _parts = new List<Part>();
            _id = -1;
            _idCounter = 0;
        }

        public int AddParts(string Name, string Brand, string Infos, int Price, BuyType BType)
        {
            int id = _idCounter;
            _idCounter++;

            Part p = new Part();

            p.Id = id;
            p.Name = Name;
            p.Brand = Brand;
            p.Info = Infos;
            p.Price = Price;
            p.BuyType = BType;

            _parts.Add(p);

            return id;
        }

        public void DeleteParts(int Id)
        {
            for (int it = 0; it < _parts.Count; it++)
            {
                if (_parts[it].Id == Id)
                {
                    _parts.RemoveAt(it);
                    break;
                }
            }
        }

        public void ModifyParts(int PartID, string Name, string Brand, string Infos, int Price, BuyType BType)
        {
            for (int it = 0; it < _parts.Count; it++)
            {
                if (_parts[it].Id == PartID)
                {
                    _parts[it].Name = Name;
                    _parts[it].Brand = Brand;
                    _parts[it].Info = Infos;
                    _parts[it].Price = Price;
                    _parts[it].BuyType = BType;
                    break;
                }
            }
        }

        public List<int> GetParts()
        {
            List<int> temp = new List<int>();

            for (int it = 0; it < _parts.Count; it++)
                temp.Add(_parts[it].Id);
            return temp;
        }

        public Part GetInfosPart(int PartID)
        {
            for (int it = 0; it < _parts.Count; it++)
            {
                if (_parts[it].Id == PartID)
                    return _parts[it];
            }
            return new Part();
        }

        #endregion

        #region Getter & Setter

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public string Brand
        {
            get { return _brand; }
            set { _brand = value; }
        }

        public string Model
        {
            get { return _model; }
            set { _model = value; }
        }

        public BikeType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public int Cylinder
        {
            get { return _cylinder; }
            set { _cylinder = value; }
        }

        public DateTime Production_date
        {
            get { return _dateProd; }
            set { _dateProd = value; }
        }

        public DateTime Buy_date
        {
            get { return _dateBuy; }
            set { _dateBuy = value; }
        }

        public int Insurance
        {
            get { return _insurancePrice; }
            set { _insurancePrice = value; }
        }

        public int Argus
        {
            get { return _argus; }
            set { _argus = value; }
        }

        public string Infos
        {
            get { return _infos; }
            set { _infos = value; }
        }

        public BuyType Buy_Type
        {
            get { return _bType; }
            set { _bType = value; }
        }

        public List<Part> Parts
        {
            get { return _parts; }
            set { _parts = value; }
        }

        #endregion

    }
}
